/**
 * @param {string} s
 * @return {string}
 */
var makeFancyString = function (s) {
  let str = '',
    count = 1
  str += s[0]
  for (let i = 1; i < s.length; i++) {
    if (s[i] == s[i - 1]) {
      count++
      if (count < 3) {
        str += s[i]
      }
    } else {
      str += s[i]
      count = 1
    }
  }
  return str
}

makeFancyString('aab')
